
    <script>
        ROOT_URL = "{$baseroot?$baseroot:''}";
    </script>
    {/* 载入框架&插件CSS */}
    <link href="__libs__/layer/skin/layer.css?v=__lkversion__" type="text/css" rel="stylesheet" />
    <link href="__libs__/amaze/css/amazeui.min.css?v=__lkversion__" type="text/css" rel="stylesheet" />

    {/* 载入框架&插件JS */}
    <script type="text/javascript" src="__libs__/jquery/jquery.min.js?v=__lkversion__"></script>
    <script src="__libs__/jquery/jquery.form.min.js?v=__lkversion__" type="text/javascript"></script>
    <script src="__libs__/jquery/jquery.cookie.js?v=__lkversion__" type="text/javascript"></script>
    <script src="__libs__/layer/layer.js?v=__lkversion__" type="text/javascript"></script>
    <script src="__libs__/amaze/js/amazeui.min.js?v=__lkversion__" type="text/javascript"></script>
    <script src="__libs__/layui/layui.js?v=__lkversion__" type="text/javascript"></script>
    <link href="__libs__/layui/css/layui.css?v=__lkversion__" rel="stylesheet">
    <link href="__libs__/bootstrap/bootstrap.min.css?v=__lkversion__" type="text/css" rel="stylesheet"/>
    {/* 载入项目 CSS & JS */}
    <link href="__style__/admin/common.css?v=__lkversion__" type="text/css" rel="stylesheet" />
    <link href="__style__/admin/admin.css?v=__lkversion__" type="text/css" rel="stylesheet" />
    <link href="__style__/admin/reload.css?v=__lkversion__" type="text/css" rel="stylesheet" />
    <script src="__script__/admin/functions.js?v=__lkversion__" type="text/javascript"></script>
    <link href="__style__/admin/index.css" type="text/css" rel="stylesheet" />
    <link href="__style__/admin/index_me.css?v=__lkversion__" type="text/css" rel="stylesheet" />
    <link href="__style__/admin/set.css?v=__lkversion__" type="text/css" rel="stylesheet" />
    <script src="__script__/admin/common_me.js?v=__lkversion__" type="text/javascript"></script>
    <script src="__libs__/push/pusher.min.js?v=__lkversion__" type="text/javascript"></script>
    <script src="__libs__/adapter.js?v=__lkversion__"></script>
    <script type="application/javascript">
        var mediaStreamTrack;
        var WEB_SOCKET_SWF_LOCATION = "__libs__/web_socket/WebSocketMain.swf";
        var WEB_SOCKET_DEBUG = true;
        var WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;
        var chat_data =Array();
        var record;
        var choose_lock = false;
        var myTitle = document.title;
        var msgreminder = {:config('setting.msgreminder')};
        var config ={
            'app_key':'{$app_key}',
            'whost':'{$whost}',
            'value':{$value},
            'wport':{$wport}
        };
        function titleBlink(){
            record++;

            if(record === 3){
                record =1;
            }

            if(record === 1){
                document.title='【 】'+myTitle;
            }

            if(record === 2){
                document.title='【消息】'+myTitle;
            }

            if(record > 3){
                getwaitnum();
                return;
            }

            setTimeout("titleBlink()",500);//调节时间，单位毫秒。
        }

        layui.use('element', function () {
            var element = layui.element;
        });
        var wolive_connect =function () {
            pusher = new Pusher('{$app_key}', {
                encrypted: {$value}
                , enabledTransports: ['ws']
                , wsHost: '{$whost}'
                , {$port}: {$wport}
        , authEndpoint: ROOT_URL + '/admin/login/auth'
                ,disableStats: true
        });

            var web = "{$arr['business_id']}";
            var value ="{$arr['service_id']}";
            // 私人频道
            var channelme = pusher.subscribe("ud" + value);
            channelme.bind("on_notice", function (data) {
                if(data.message.type == 'change'){
                    layer.msg(data.message.msg);
                }
                getchat();
                getwait();
            });

            channelme.bind("on_chat", function (data) {
                $.cookie("cu_com",'');
                layer.msg('该访客被删除');
                getchat();
            });
            // 公共平道
            var channelall = pusher.subscribe("all" + web);
            channelall.bind("on_notice", function (data) {
                if({$arr['groupid']} == 0 || {$arr['groupid']} == data.message.groupid){
                    layer.msg(data.message.msg, {offset: "20px"});
                }

                if({$arr['groupid']} != data.message.groupid){

                    layer.msg('该用户向其他分组咨询！', {offset: "20px"});
                }

                getwait();
                getchat();

            });

            var channel =pusher.subscribe("kefu" + value);
            // 发送一个推送
            channel.bind("callbackpusher",function(data){
                $.post("{:url('admin/set/callback','',true,true)}",data,function(res){
                })
            });

            // 接受视频请求
            channel.bind("video",function (data) {
                getchat();
                var msg = data.message;
                var cha = data.channel;
                var cid = data.cid;
                var avatar =data.avatar;
                var username =data.username;
                layer.open({
                    type: 1,
                    title: '申请框',
                    area: ['260px', '160px'],
                    shade: 0.01,
                    fixed: true,
                    btn: ['接受', '拒绝'],
                    content: "<div style='position: absolute;left:20px;top:15px;'><img src='"+avatar+"' width='40px' height='40px' style='border-radius:40px;position:absolute;left:5px;top:5px;'><span style='width:100px;position:absolute;left:70px;top:5px;font-size:13px;overflow-x: hidden;'>"+username+"</span><div style='width:90px;height:20px;position:absolute;left:70px;top:26px;'>"+msg+"</div></div>",
                    yes: function () {
                        layer.closeAll('page');
                        var str='';
                        str+='<div class="videos">';
                        str+='<video id="localVideo" autoplay></video>';
                        str+='<video id="remoteVideo" autoplay class="hidden"></video></div>';


                        layer.open({
                            type:1
                            ,title: '视频'
                            ,shade:0
                            ,closeBtn:1
                            ,area: ['440px', '378px']
                            ,content:str
                            ,end:function(){


                                mediaStreamTrack.getTracks().forEach(function (track) {
                                    track.stop();
                                });

                            }
                        });
                        try{
                            connenctVide(cid);
                        }catch(e){
                            console.log(e);
                            return;
                        }

                    },
                    btn2:function(){
                        var sid = $('#channel').text();
                        $.ajax({
                            url:ROOT_URL+'/admin/set/refuse',
                            type:'post',
                            data:{channel:cha}
                        });

                        layer.closeAll('page');
                    }
                });
            });

            channel.bind('bind-wechat',function(data){
                layer.open({
                    content: data.message
                    ,btn: ['确定']
                    ,yes: function(index, layero){
                        location.reload();
                    }
                    ,cancel: function(){
                        return false;
                    }
                });
            });


            channel.bind('getswitch',function(data){
                layer.alert(data.message);
                getchat();
            });

            // 接受拒绝视频请求
            channel.bind("video-refuse",function (data) {
                layer.alert(data.message);
                layer.closeAll('page');
            });
            // 接受消息
            channel.bind("cu-event", function (data) {
                if("{$voice}" == 'open'){
                    audioElementHovertree = document.createElement('audio');
                    audioElementHovertree.setAttribute('src', "{$voice_address}");
                    audioElementHovertree.setAttribute('autoplay', 'autoplay');
                }
                var debug, portrait,showtime;
                var cdata = $.cookie("cu_com");

                if (cdata) {
                    var json = $.parseJSON(cdata);
                    debug = json.visiter_id;
                    portrait = json.avatar;
                } else {
                    debug = "";

                }

                if($.cookie("time") == ""){
                    time =data.message.timestamp;
                    $.cookie("time",time);
                    var mydate =new Date(time*1000);
                    showtime =mydate.getHours()+":"+mydate.getMinutes();
                }else{
                    time =$.cookie("time");
                    if((data.message.timestamp - time) >60){
                        var mydate =new Date(data.message.timestamp*1000);
                        showtime =mydate.getHours()+":"+mydate.getMinutes();
                    }else{
                        showtime ="";
                    }
                    $.cookie("time",data.message.timestamp);
                }
                var msg = '';
                msg += '<li class="chatmsg"><div class="showtime">' +showtime+ '</div><div style="position: absolute;left:3px;">';
                msg += '<img class="my-circle  se_pic" src="' + portrait + '" width="50px" height="50px"></div>';
                msg += "<div class='outer-left'><div class='customer'>";
                msg += "<pre>" + data.message.content + "</pre>";
                msg += "</div></div>";
                msg += "</li>";
                var str = data.message.content;
                if (data.message.visiter_id == debug) {
                    $(".conversation").append(msg);
                    getwatch(data.message.visiter_id);


                    str.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {

                        var pos = capture.lastIndexOf("/");
                        var value = capture.substring(pos + 1);

                        if (value.indexOf("emo") == 0) {
                            str = data.message.content;
                        } else {
                            str = '[图片]';
                        }
                    });

                    str = str.replace(/<div><a[^<>]+><i>.+?<\/i>.+?<\/a><\/div>/,'[文件]');
                    str = str.replace(/<a[^<>]+>.+?<\/a>/,'[超链接]');
                    str =str.replace(/<img src=['"]([^'"]+)[^>]*>/gi,'[图片]');

                    $("#msg" + data.message.channel).html(str);

                    var div = document.getElementById("wrap");

                }
                getnow(data.message);
                if(div){
                    div.scrollTop = div.scrollHeight;
                }
                $("#notices-icon").removeClass('hide');

                console.log(data);
                notify(data.message.visiter_name || '新访客', {
                    body: str,
                    icon: data.message.avatar
                }, function(notification) {
                    //可直接打开通知notification相关联的tab窗口
                    window.focus();
                    notification.close();
                    console.log('#v'+data.message.channel+' .visit_content');
                    $('#v'+data.message.channel+' .visit_content').trigger('click');
                    // $('#v'+data.message.channel+' .visit_content').trigger('click');
                });
            });


            // 通知 游客离线
            channel.bind("logout", function (data) {

                //表示访客离线
                var cdata = $.cookie("cu_com");
                var chas;
                if (cdata) {
                    var jsondata = $.parseJSON(cdata);
                    chas = jsondata.channel;
                }

                if (chas == data.message.chas) {
                    //头像变灰
                    $("#v_state").text("离线");
                }

                $("#img" + data.message.chas).addClass("icon_gray");
                getchat();

            });

            channel.bind("geton", function (data) {

                //表示访客在线
                var cdata = $.cookie("cu_com");
                var chas;
                if (cdata) {
                    var jsondata = $.parseJSON(cdata);
                    chas = jsondata.channel;
                }
                if (chas == data.message.chas) {
                    //头像变亮
                    $("#img" + data.message.chas).removeClass("icon_gray");
                    $("#v_state").text("在线");
                }

                $("#img" + data.message.chas).removeClass("icon_gray");
                getchat();

            });

            pusher.connection.bind('state_change', function(states) {

                if(states.current == 'unavailable' || states.current == "disconnected" || states.current == "failed" ){

                    pusher.unsubscribe("kefu" + value);
                    pusher.unsubscribe("all" + web);
                    pusher.unsubscribe("ud" + value);

                    if (typeof pusher.isdisconnect == 'undefined') {
                        pusher.isdisconnect = true;

                        pusher.disconnect();
                        delete pusher;

                        window.setTimeout(function(){
                            wolive_connect();
                        },1000);
                    }


                    $(".profile").text('离线');
                }
            });

            pusher.connection.bind('connected', function() {
                $(".profile").text('在线');
            });
        }


        function showpage(obj){

            var value =$(obj).attr("name");
            var key =$(obj).attr("id");
            layer.tips(value, '#'+key,{tips: [4, '#2F4050']});
        }



    </script>

    <script type="text/javascript" src="__libs__/web_socket/swfobject.js?v=__lkversion__"></script>
    <script type="text/javascript" src="__libs__/web_socket/web_socket.js?v=__lkversion__"></script>
    <script type="text/javascript" src="__script__/admin/online.js"></script>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link href="__style__/admin/ymwl_common.css?v=__lkversion__" type="text/css" rel="stylesheet" />
    <style>
        .my-setting {
            margin: 10px 0px;
            background: #fff;
            border-radius: 8px;
        }

        .my-setting .head {
            height: 40px;
            line-height: 40px;
            background: #F5FAFF;
            display: flex;
            justify-content: space-between;
            border-radius: 8px;
        }

        .my-setting .head .title {
            padding-left: 16px;
        }

        .my-setting .head .action {
            padding: 0px 15px;
        }
        .my-setting .contents{
            font-size: 13px;
            color: #555555;
        }

        .copy-js-content{
            display: block;
            width: 100%;
            padding: 10px;
            border: none;
            resize: none;
            background: rgba(240, 240, 240, .8);
            margin: 5px 0;
            font-size: 16px;
            font-weight: bold;
        }
        .layui-btn.layui-btn-normal{
            color: #1E9FFF;
            background: #ffffff;
            border: 1px solid #1E9FFF;
            height: 32px;
            line-height: 32px;
            margin-left: 20px;
            border-radius: 15px;
        }
        #minjs{
            padding: 16px;
            font-size: 14px;
            color: #ff5c5c;
        }
        #wolive-js , #wechat-mp,#personal{
            padding-left: 16px;
            margin-bottom: 10px;
            color: #555555;
            font-size: 14px;
            border-radius: 8px;
            background: #f7f7f7;
        }
        #container{
            background-color: #fff;
        }
        #test-form-theme *,#test-form *,.layui-btn-container *,.layui-colorpicker-main-input *{box-sizing:content-box;-webkit-box-sizing:content-box; }
        .layui-colorpicker-main-input input.layui-input{width: 130px;}
        .layui-form-item{margin-bottom: 0;}
    </style>

<script type="text/javascript">
    var width =document.body.clientWidth;
    var changeall =function(){
        $("#layout-west").css("width","160px");
        $("#layout-center").css({"position":"absolute","left":"160px","width":(width-160)+"px"});
        $(".info").removeClass("hide");
        $(".west_foot2").removeClass("hide");
        $(".west_foot1").addClass("hide");
        if($(".notices")[0].textContent > 0) {
            $('.notices').removeClass("hide");
            $('.notices-icon').addClass("hide");
        }
    }
    var changesmall =function(){
        if($(".notices")[0].textContent > 0) {
            $('.notices').removeClass("hide");
        }
    }
    setInterval(function(){
        changesmall();
    },1000);
    var is_bind_wechat = 1;
    if (!is_bind_wechat) {
        var index = layer.open({
            content: '您还未绑定微信，无法接受模板消息'
            ,btn: ['前去绑定','忽略']
            ,yes: function(index, layero){
                $.ajax({
                    url: "/admin/index/qrcode.html",
                    dataType: 'json',
                    success: function (res) {
                        layer.close(index);
                        layer.open({
                            type: 1,
                            content: '<img  src="'+res.data+'"/>',
                        });
                    }
                });
                return false;
            },
            btn2: function(index, layero){
                //按钮【按钮二】的回调

                //return false 开启该代码可禁止点击该按钮关闭
            }
            ,cancel: function(){

            }
        });
    }
</script>
<div id="container" >
    <div class="front">
        <div class="my-setting">
                <div class="head">
                    <div class="title">
                        部署网页组件（推荐）：网页咨询组件同时支持桌面网站和移动网站，提供强大的用户行为采集能力和系统对接能力
                    </div>
                   
                </div>
                <br />
                <div class="contents">
                    聊天框样式：
                    <select name="type" id="type" onchange="swith()" style="margin-left:20px;padding: 3px;font-size: 14px;border-radius: 15px;border: 1px solid #e5e3e9;height: 32px;">
                            <!--<option value="0" selected>标准窗口</option>
                            <option value="1">迷你窗口</option>-->
                            <option value="2" selected>自定义窗口</option>

                    </select>

                    <button class="layui-btn layui-btn-normal" onclick="build()">更新JS文件</button>
                    <!--<button id="bulidhtml" class="layui-btn layui-btn-normal" onclick="show()" style="margin-left:10px
">生成html</button>
                    <button id="buildwechat" class="layui-btn layui-btn-normal" style="margin-left:10px
" onclick="buildmp()">生成微信公众号链接</button>
                    <button id="buildpersonal" class="layui-btn layui-btn-normal" style="margin-left:10px
" onclick="buildpersonal()">生成我的专属链接</button>-->
                    {:hook('generatelinkhook', ['id'=>1])}
                    {:hook('testhook', ['id'=>1])}
                </div>
            <br/>
            <div class="layui-card" style="background-color: #F3F3F3;" id="diy-kf-site">
                <div class="layui-card-header">自定义设置(请设置好再点击生成)</div>
                <div class="layui-card-body">
                    <form class="layui-form" id="form-diy">
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: 120px">开启弹窗</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" checked name="isopen" lay-skin="switch" lay-filter="switchTest" lay-text="开|关">
                            </div>
                            <div class="layui-form-mid layui-word-aux">只对自定义窗口生成js有效</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: 120px">弹窗延时</label>
                            <div class="layui-input-inline">
                                <input type="text" name="open_delay" placeholder="聊天窗口延时时间" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">单位秒，开启弹窗有效（只对自定义窗口生成js有效）</div>
                        </div>
                        <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 120px">弹窗高度</label>
                        <div class="layui-input-inline">
                            <input type="text" name="m_height" placeholder="聊天窗口弹窗高度" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">单位像素，只针对手机端有效（只对自定义窗口生成js有效）</div>
                    </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: 120px">悬浮条背景色</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="m_kfbtbg" placeholder="请选择颜色" class="layui-input" id="m_kfbtbg" value="#13c9cb">
                            </div>
                            <div class="layui-inline">
                                <div id="test-form"></div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-form-mid layui-word-aux">客服悬浮条背景色</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: 120px">主题颜色</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="theme" placeholder="请选择颜色" class="layui-input" id="theme" value="#13c9cb">
                            </div>
                            <div class="layui-inline">
                                <div id="test-form-theme"></div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-form-mid layui-word-aux">聊天窗口主题色</div>
                            </div>

                        </div>
                    </form>
                </div>
            </div>

               <div class="method" >
                      <div id="codearea" class="hide">
                          <pre id="wechat-mp" class="copy-js-content hide layui-code" style="height: 250px" readonly="">

                          </pre>
                          <pre id="personal" class="copy-js-content hide" readonly="">

                          </pre>
                        <pre id="wolive-js" class="copy-js-content" readonly>
                            部署如下代码
                            <div class="layui-code">

                            </div>
                        </pre>
                        <pre id="frontjs" class="copy-js-content hide" style="height: 250px">
                            部署如下代码
                            <div class="layui-code">

                            </div>
                     </pre>
                     <pre id="minjs" class="copy-js-content hide" style="margin-bottom: 50px">
                        如果需要添加自身网站用户数据，请部署到上面代码之前，按注释要求添加：
                         <div class="layui-code">
                              &lt;script type="text/javascript">
                            &nbsp;&nbsp;var ai_service={};
                            &nbsp;&nbsp;ai_service.visiter_id='';//访客id
                            &nbsp;&nbsp;ai_service.visiter_name='';//访客昵称
                            &nbsp;&nbsp;ai_service.avatar='';//访客头像绝对路径
                            &nbsp;&nbsp;ai_service.product='{}';//json数据字符串
                            &lt;/script>
                         </div>
                        /**
                        格式如下：
                            {"pid":1,"title":" Apple MacBook Air ","img":"http://www.domain.com/assets/images/pro.jpg","info":"13.3英寸笔记本电脑 银色(2017款Core i5 处理器/8GB内存/128GB闪存 MQD32CH/A)","price":"￥7588.00","url":"http://www.domain.com/demo/index/product1"}
                         */
                     </pre>

                   
                    </div>
               </div>        
        </div>
    </div>

</div>
<div id="demo"></div>
<script>

    layui.use(['form','code','colorpicker'], function(){
        var form = layui.form,colorpicker = layui.colorpicker;
        //各种基于事件的操作，下面会有进一步介绍
        colorpicker.render({
            elem: '#test-form'
            ,color: '#13c9cb'
            ,done: function(color){
                $('#m_kfbtbg').val(color);
            }
        });
        colorpicker.render({
            elem: '#test-form-theme'
            ,color: '#13c9cb'
            ,done: function(color){
                $('#theme').val(color);
            }
        });
    });
var swith=function(){

    $type =$("#type").val();
    if($type == 0){
     $("#bulidhtml").removeClass('hide');
     $("#codearea").addClass('hide');
        // $("#diy-kf-site").addClass('hide');
     $("#wolive-js").addClass('hide');
     $("#frontjs").addClass('hide');
     $("#ymwl-kefu").remove();
     $('#buildwechat').removeClass('hide');
     $('#buildpersonal').removeClass('hide');
    }else if($type == 1){
     $("#bulidhtml").addClass('hide');
        // $("#diy-kf-site").addClass('hide');
     $("#codearea").addClass('hide');
     $("#wolive-js").addClass('hide');
     $('#minjs').addClass('hide');
     $("#ymwl-kefu").remove();
     $('#buildwechat').addClass('hide');
     $('#buildpersonal').addClass('hide');
    } else if($type == 2){
        $("#bulidhtml").addClass('hide');
        $("#codearea").addClass('hide');
        $("#wolive-js").addClass('hide');
        $('#minjs').addClass('hide');
        $("#ymwl-kefu").remove();
        // $("#diy-kf-site").removeClass('hide');
        $('#buildwechat').addClass('hide');
        $('#buildpersonal').addClass('hide');
    }
}

var build =function(){
    $('#wechat-mp').addClass('hide');

    $type =$("#type").val();
     if($type == 0 ){
        $("#frontjs").addClass('hide');
        $.ajax({
           url:ROOT_URL+'/admin/set/createFrontjs',
           dataType:'json',
            data:$("#form-diy").serialize(),
           success:function(res){
            if(res.code == 0){
              layer.msg(res.msg,{icon:1,end:function(){
                $("#wolive-js").removeClass('hide');
                $("#codearea").removeClass('hide');
                $("#minjs").removeClass('hide');
                var str ='&lt;script src="'+res.data+'" charset="UTF-8">&lt;/script>';
                $("#wolive-js .layui-code").html(str);
                var newstr='<script src="'+res.data+'">';
                $('#ymwl-kefu').remove();
                $("#demo").html(newstr);

              }});
            }else{
              layer.msg(res.msg,{icon:2});
            }
           }
        });
     }else if($type == 1){
       $.ajax({
         url:ROOT_URL+'/admin/set/createMinjs',
         dataType:'json',
           data:$("#form-diy").serialize(),
           type:"POST",   //请求方式
         success:function(res){
          if(res.code == 0){
            layer.msg(res.msg,{icon:1,end:function(){
              $("#wolive-js").removeClass('hide');
              $("#codearea").removeClass('hide');
              $("#frontjs").addClass('hide');
              $("#minjs").removeClass('hide');
              var str ='&lt;script src="'+res.data+'" charset="UTF-8"> &lt;/script>';
              $("#wolive-js .layui-code").html(str);
              layui.code({elem:'#wolive-js .layui-code',about: false});
              var newstr='<script src="'+res.data+'">';
                    $('#ymwl-kefu').remove();
                    $('#wolive-talk').remove();
                    $("#demo").html(newstr);
            
            }});
          }else{
            layer.msg(res.msg,{icon:2});
          }
         }
       });
     }else if($type == 2){
         $.ajax({
             url:ROOT_URL+'/admin/set/createMinDiyjs',
             dataType:'json',
             data:$("#form-diy").serialize(),
             type:"POST",   //请求方式
             success:function(res){
                 if(res.code == 0){
                     layer.msg(res.msg,{icon:1,end:function(){
                             $("#wolive-js").removeClass('hide');
                             $("#codearea").removeClass('hide');
                             $("#frontjs").addClass('hide');
                             $("#minjs").removeClass('hide');
                             var str ='&lt;script src="'+res.data+'" charset="UTF-8"> &lt;/script>';
                             $("#wolive-js .layui-code").html(str);
                             layui.code({elem:'#wolive-js .layui-code',about: false});
                             var newstr='<script src="'+res.data+'">';
                             $('#personal').remove();
                             $('#ymwl-kefu').remove();
                             $('#wolive-talk').remove();
                             $('#blzxMinChatWindowDiv').remove();
                             $("#demo").html(newstr);

                         }});
                 }else{
                     layer.msg(res.msg,{icon:2});
                 }
             }
         });
     }
}
var domWechatMp=$('#wechat-mp');
var buildmp = function(){
    $type =$("#type").val();
    if($type == 0){
        $.ajax({
            url:"{:url('admin/set/createWechatUrl','',true,true)}",
            dataType:'json',
            data:$("#form-diy").serialize(),
            type:"POST",   //请求方式
            success:function(res){
                if(res.code == 0){
                    layer.msg(res.msg,{icon:1,end:function(){
                            $("#codearea").removeClass('hide');
                            $("#frontjs").addClass('hide');
                            $("#wolive-js").addClass('hide');
                            $("#minjs").addClass('hide');
                            $("#personal").addClass('hide');
                            domWechatMp.removeClass('hide');
                            domWechatMp.html(res.data);
                        }});
                }else{
                    layer.msg(res.msg,{icon:2});
                }
            }
        });

    }
};
var domPersonal=$("#personal");
var buildpersonal = function () {
    $type =$("#type").val();
    if($type == 0){
        $("#codearea").removeClass('hide');
        $("#frontjs").addClass('hide');
        $("#wolive-js").addClass('hide');
        $("#minjs").addClass('hide');
        $('#wechat-mp').addClass('hide');
        var theme=$('#theme').val();
        theme=theme.replace("#","");
        domPersonal.removeClass('hide');
        domPersonal.text("{$action}/index/index/home?visiter_id=&visiter_name=&avatar=&business_id={$login['business_id']}&groupid={$login['groupid']}&special={$login['service_id']}&theme="+theme);
    }
};

var show =function(){
    $('#wechat-mp').addClass('hide');
    $('#personal').addClass('hide');
   $type =$("#type").val();
   if($type == 0){
       $.ajax({
           url:ROOT_URL+'/admin/set/createHtml',
           dataType:'json',
           data:$("#form-diy").serialize(),
           type:"POST",   //请求方式
           success:function(res){
               if(res.code == 0){
                   layer.msg(res.msg,{icon:1,end:function(){
                           $("#codearea").removeClass('hide');
                           $("#wolive-js").addClass('hide');
                           $("#frontjs").removeClass('hide');
                           $("#minjs").addClass('hide');
                           $('#ymwl-kefu').remove();
                           $("#demo").html(res.data);
                           $("#frontjs .layui-code").text(res.data);
                           layui.code({elem:'#frontjs .layui-code',about: false});
                       }});
               }else{
                   layer.msg(res.msg,{icon:2});
               }
           }
       });

   }
}

</script>